package com.jp.boot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;

import java.util.Arrays;

@SpringBootApplication
public class BootApplication implements CommandLineRunner {

    // 未指定端口号时不能使用
  /*  @Value("${local.server.port}")
    public String port;*/

    @Autowired
    Environment environment;

    public String getPort() {
        return environment.getProperty("local.server.port");

    }

    public static void main(String[] args) {
        System.out.println("args " + Arrays.toString(args));
        SpringApplication application = new SpringApplication(BootApplication.class);
        // 关闭banner
        application.setBannerMode(Banner.Mode.OFF);
        application.run(args);
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println("Port----" + getPort());
    }
}
